package org.jeecg.modules.flower.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.flower.entity.FlowerLose;
import org.jeecg.modules.flower.entity.FlowerOutorderHZ;
import org.jeecg.modules.flower.entity.FlowerTagInfo;
import org.jeecg.modules.flower.vo.CountNumData;
import org.jeecg.modules.flower.vo.ScreenData;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description: 标签信息
 * @Author: jeecg-boot
 * @Date: 2021-08-26
 * @Version: V1.0
 */
public interface IFlowerTagInfoService extends IService<FlowerTagInfo> {
    IPage<FlowerTagInfo> queryListAndBase(IPage<FlowerTagInfo> page, Wrapper<FlowerTagInfo> queryWrapper);


    IPage<ScreenData> selectTablePage(IPage<ScreenData> page, Wrapper<ScreenData> queryWrapper);

    List<ScreenData> poleLengthCom();

    List<ScreenData> monthWorkCom();

    CountNumData currentSortFlower();

    LinkedHashMap<String, Object> queryPoleLevelYear();

    LinkedHashMap<String, Object> queryPoleLevelMonth();

    List<LinkedHashMap<String, Object>> queryVariety();

    /**
     * 统计采后处理上周的鲜花处理信息种类-匝数-总数
     * 每匝的数量现在是写死在代码中，根据字典（planting_packing_specifications）中的item_value手工判断，更改字典需要更改这里的SQL
     *
     * @return 统计信息的字符串
     */
    String flowerCountMessage();

    Integer flowerLose(FlowerLose flowerLose) throws Exception;

    void updateStateToLose(List<String> tagInfoIds) throws Exception;


    //台账的查询接口
    IPage<FlowerTagInfo> getListByhose(IPage<FlowerTagInfo> page, Wrapper<FlowerTagInfo> wrapper);

    //台账总数的查询接口
    Integer getTaginfoCount(  Wrapper<FlowerTagInfo>  wrapper  );


    /**
     * 扣减库存
     *
     * @param outOrderInfoID
     * @param varietyCode
     * @param storehouse
     * @param packingSpecifications
     * @param flowerPoleLength
     * @param number
     * @return
     */
    Integer outTagInfo(String outOrderInfoID,String sourceBase,String sourceGreenhouse, String variety, String varietyCode, String storehouse, String classes,String cost,String packingSpecifications, String flowerPoleLength, Integer number, Date stockOutTime);

    /**
     * 返还库存
     *
     * @param outOrderInfoID
     * @return
     */
    Integer BackOutTagInfo(String outOrderInfoID);

    /**
     * 扣减库存--预出库
     *
     * @param outOrderInfoID
     * @param varietyCode
     * @param storehouse
     * @param packingSpecifications
     * @param flowerPoleLength
     * @param number
     * @return
     */
    Integer outPreTagInfo(String outOrderInfoID,String sourceBase,String sourceGreenhouse,  String channel, String accountno, String variety, String varietyCode, String storehouse,String classes,String cost, String packingSpecifications, String flowerPoleLength, Integer number, Date stockOutTime);

    /**
     * 返还库存--预出库
     *
     * @param outOrderInfoID
     * @return
     */
    Integer BackPreOutTagInfo(String outOrderInfoID);


    /**
     * 扣减库存-生成日志---PDA扫码出库
     *
     * @return java.lang.Integer
     * @descriptionauthor
     * @author gf
     * 2022-11-9 14:11
     * [orderID, map, stockOutTime]
     */
    Integer outTagInfoForPDA(String orderID, Map<String, FlowerOutorderHZ> map, Date stockOutTime);


    /**
     * 扣减库存- ==预出库---PDA扫码预出库
     *
     * @return java.lang.Integer
     * @descriptionauthor
     * @author gf
     * 2022-11-10 9:43
     * [orderID, channel, accountno, map, stockOutTime]
     */
    Integer outPreTagInfoPDA(String orderID, String channel, String accountno, Map<String, FlowerOutorderHZ> map, Date stockOutTime);

}
